commonlibsse_ng\re\t/
TESFullName.rs

1use crate::re::BSFixedString::BSFixedString;
2use crate::re::BaseFormComponent::{BaseFormComponent, BaseFormComponentVtbl};
3use crate::re::offsets_rtti::RTTI_TESFullName;
4use crate::re::offsets_vtable::VTABLE_TESFullName;
5use crate::rel::id::VariantID;
6use core::ffi::c_char;
7
8#[repr(C)]
9#[derive(Debug, Clone, PartialEq)]
10pub struct TESFullName {
11    pub __base: BaseFormComponent, // 0x00
12    pub fullName: BSFixedString,   // 0x08 - FULL
13}
14const _: () = assert!(std::mem::size_of::<TESFullName>() == 0x10);
15
16impl TESFullName {
17    pub const RTTI: VariantID = RTTI_TESFullName;
18    pub const VTABLE: [VariantID; 1] = VTABLE_TESFullName;
19
20    #[commonlibsse_ng_derive_internal::relocate_fn(se_id = 22318, ae_id = 22791)]
21    pub fn set_full_name(&mut self, name: *const c_char) {}
22
23    /// Returns a reference to the virtual function table for `TESFullName`.
24    ///
25    /// # Panics
26    ///
27    /// Panics if the vtable pointer is null.
28    #[inline]
29    fn get_vtable(&self) -> &TESFullNameVtbl {
30        let vtbl = self.__base.vtable.cast::<TESFullNameVtbl>();
31        if vtbl.is_null() {
32            #[cfg(feature = "tracing")]
33            tracing::error!("TESFullName::vtbl is null — object: {:p}", self);
34            panic!("TESFullName::vtbl is null");
35        }
36
37        unsafe { &*vtbl }
38    }
39}
40
41#[repr(C)]
42#[derive(Debug)]
43pub struct TESFullNameVtbl {
44    /// override
45    /// - `CxxDrop`(0x00):
46    /// - `InitializeDataComponent`(0x01): `{ name = ""; }`
47    /// - `ClearDataComponent`(0x02): `{ return; }`
48    /// - `CopyComponent`(0x03):
49    pub __base: BaseFormComponentVtbl,
50    pub GetFullNameLength: fn(this: *const TESFullName) -> u32, // 0x04
51    pub GetFullName: fn(this: *const TESFullName) -> *const c_char, // 0x05
52}
53const _: () = {
54    const VFUNC_COUNT: usize = 0x5;
55
56    const EXPECTED_SIZE: usize = (VFUNC_COUNT + 1) * core::mem::size_of::<usize>();
57    assert!(core::mem::size_of::<TESFullNameVtbl>() == EXPECTED_SIZE);
58};
59
60pub trait TESFullNameVtblTrait {
61    fn GetFullNameLength(this: &TESFullName) -> u32; // 0x04
62    fn GetFullName(this: &TESFullName) -> *const c_char; // 0x05
63}
64
65impl TESFullNameVtblTrait for TESFullName {
66    #[inline]
67    fn GetFullNameLength(this: &TESFullName) -> u32 {
68        let vtable = this.get_vtable();
69        let func = vtable.GetFullNameLength;
70        func(this)
71    }
72
73    #[inline]
74    fn GetFullName(this: &TESFullName) -> *const c_char {
75        let vtable = this.get_vtable();
76        let func = vtable.GetFullName;
77        func(this)
78    }
79}